import java.lang.reflect.*;

class ClassBase {
    void show() {
        System.out.printf("Base Show!\n");
    }
}

public class ClassTest {
    static public void main(String [] args) throws Exception {
        // Class c = AnnotationTest.cltss;
        // Class c = ClassLoader.getSystemClassLoader().loadClass("AnnotationTest");
        Class c = Class.forName("AnnotationTest");
        // new AnnotationTest();
        AnnotationTest at = (AnnotationTest)c.newInstance();

        Field f = at.getClass().getField("member");
        int m = f.getInt(at);
        System.out.printf("AnnotationTest %s: %d\n", f.getName(), m);

        Method [] mt = at.getClass().getMethods();
        for (Method t : mt) {
            if (t.getName().equals("test")) {
                t.invoke(at, new String("hello world"));
            } else {
                // System.out.println(t);
            }
        }
        // mt.invoke("反射调用对象的方法");

        // MyAnnotation ma = at.getClass().getAnnotation(MyAnnotation.class);
        MyAnnotation ma = f.getAnnotation(MyAnnotation.class);
        System.out.println(ma.id() + " : " + ma.name());
    }

}
